<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>新增订单</title>
    <!--{include file='comm/comm_cal.tpl'}-->
    <!--{include file="comm/icheck.tpl"}-->
    <!--add by JunHui.Li FUN-BK-0050 模糊快捷查询促销渠道功能 引入的文件 start-->
    <script language="JavaScript" src="/framework/select2/js/select2.full.js" type="text/javascript"></script>

    <script language="JavaScript" src="/framework/select2/js/prettify.min.js" type="text/javascript"></script>

    <link rel="stylesheet" href="/framework/select2/css/select2.min.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="/framework/select2/css/font-awesome.min.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="/framework/select2/css/prettify.css" type="text/css" media="screen" />
    <!--add by JunHui.Li FUN-BK-0050 模糊快捷查询促销渠道功能 引入的文件 end-->
    <style type="text/css">
        body {
            font-size: 16px;
        }
        .form-horizontal .form-group {
            margin-right: 0;
            margin-left: 0;
        }
        .op {
            position: relative;
            float: right;
            top: 3px;
        }
        .popup-content{
            max-height: 400px !important;
        }
        #general_line td {
            vertical-align: middle;
        }
    </style>
</head>

<body>
<div class="container" style="width:99%;margin: 0 auto;">

<div class="title">
    <h2 class="tac">新增订单</h2>
</div>


<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">订单信息</h3>
    </div>
    <div class="panel-body form-inline">
        <input type="hidden" id="properties" name="properties" value="<!--{$properties}-->">
        <input type="hidden" id="operateType" name="operateType" value="<!--{$operateType}-->">
        <table class="ebsig-text">
            <tr>
                <td>
                    城市：<select class="form-control input-sm" id="billCity">
                        <!--{foreach from=$city_array item=city}-->
                        <option value="<!--{$city.id}-->" pro="<!--{$city.parentID}-->" <!--{if $cityid == $city.id}-->selected<!--{/if}-->><!--{$city.name}--></option>
                        <!--{/foreach}-->
                    </select>
                </td>
                <td>
                    单据标识：<select class="form-control input-sm" id="urgent">
                        <!--{foreach from=$global_array.urgent item=urgent_name key=urgent}-->
                        <!--{if $urgent eq 0}-->
                        <option value="<!--{$urgent}-->">请选择</option>
                        <!--{else}-->
                        <option value="<!--{$urgent}-->"><!--{$urgent_name}--></option>
                        <!--{/if}-->
                        <!--{/foreach}-->
                    </select>
                </td>
                <td>
                    订单平台：<select class="form-control input-sm" id="billPlatform">
                        <!--{foreach from=$global_array.bill_platform item=bill_platform_name key=bill_platform}-->
                        <!--{if $bill_platform == 1}-->
                        <option value="<!--{$bill_platform}-->"><!--{$bill_platform_name}--></option>
                        <!--{/if}-->
                        <!--{/foreach}-->
                    </select>
                </td>
                <td>订单渠道：客服</td>

                <td>
                    订单类型：<select class="form-control input-sm" id="billType">
                        <!--{foreach from=$global_array.bill_type item=bill_type_name key=bill_type}-->
                        <option value="<!--{$bill_type}-->" <!--{if $bill_type eq $billType}-->selected<!--{/if}-->><!--{$bill_type_name.name}--></option>
                        <!--{/foreach}-->
                    </select>
                </td>
                <!--add by JunHui.Li FUN-BK-0050 模糊快捷查询促销渠道功能 start-->
                <td>
                    促销渠道：
                    <select class="js-example-data-array-selected form-control" id="billPromotion" name="promotionChannelID">
                        <option value="0">请选择</option>
                    </select>
                </td>
                <!--add by JunHui.Li FUN-BK-0050 模糊快捷查询促销渠道功能 end-->
            </tr>
        </table>
    </div>
</div>

<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">客户信息</h3>
    </div>
    <div class="panel-body">
        <table class="ebsig-text">
            <tr>
                <td width="26%">会员名：<!--{$customer_array.custID}--></td>
                <td width="14%">会员姓名：<!--{$customer_array.custname}--></td>
                <td width="14%">手机：<!--{$customer_array.mobile}--></td>
                <td width="26%">Email：<!--{$customer_array.email}--></td>
            </tr>
            <tr>
                <td>电话：<!--{$customer_array.phone}--></td>
                <td>会员等级：<!--{$customer_array.rankName}--></td>
                <td>会员状态：
                    <!--{if !$customer_array}-->&nbsp;<!--{elseif $customer_array.useFlg == 1}-->可用<!--{elseif $customer_array.useFlg == 2}-->禁用<!--{/if}-->
                </td>
                <td>积分：<!--{$customer_array.points|string_format:'%.0f'|default:'0'}--></td>
            </tr>
            <tr>
                <td>余额：<!--{$customer_array.cash|string_format:'%.2f'|default:'0.00'}--></td>
                <td>会员来源：<!--{$customer_array.custSourceName}--></td>
                <td>最近下单时间：<!--{$customer_array.last_bill_time}--></td>
                <td>首次下单时间：<!--{$customer_array.frist_bill_time}--></td>
            </tr>
            <tr><td colspan="4">公司人数：<!--{$companyNum}--></td></tr>
        </table>
    </div>

</div>
<div class="panel panel-default"  id='foretaste' style="display: none">
    <div class="panel-heading">
        <h3 class="panel-title">参加试吃的人数</h3>
    </div>
    <ul class="list-group radio-box"><li><input type="text" class="form-control w150" id="numPeo" name="numPeo" value=""placeholder="参加试吃的人数"></li></ul>
</div>


<!--商品信息    开始-->
<div class="panel panel-default">

    <div class="panel-heading"><h3 class="panel-title">商品信息</h3></div>

    <table class="table table-hover">
        <thead>
        <tr>
            <th width="70">商品编号</th>
            <th width="*" style="text-align: left;">商品名称</th>
            <th width="70" style="text-align: center;">购买数量</th>
            <th width="90" style="text-align: center;">规格</th>
            <th width="80" style="text-align: center;">标价</th>
            <th width="120" style="text-align: center;">售价</th>
            <th width="300" style="text-align: center;">生日牌</th>
            <th width="160" style="text-align: center;">切分</th>
            <th width="70" style="text-align: center;">配件</th>
            <th width="120" style="text-align: center;">生产备注</th>
            <th width="42" style="text-align: center;">操作</th>
        </tr>
        </thead>
        <tbody id="general_line"></tbody>
        <tbody>
        <tr>
            <td colspan="13" class="form-inline">
                <input type="text" class="form-control w150" id="goods_code" placeholder="商品编号"/>
                <input type="text" class="form-control w300" id="goods_name" placeholder="商品名称"/>
            </td>
        </tr>
        </tbody>
    </table>
</div>
<!--商品信息    结束-->

<!--订单促销    开始-->
<div class="panel panel-default" id="promotionBill" style="display: none;">
    <div class="panel-heading"><h3 class="panel-title">订单促销信息</h3></div>
    <ul class="list-group"></ul>
</div>
<!--订单促销    结束-->

<!--配送时间    开始-->
<div class="panel panel-default">

    <div class="panel-heading"><h3 class="panel-title">配送时间</h3></div>

    <div class="panel-body form-inline">
        <div id="send_time_box">
            配送时间：
            <input class="form-control w150" id="send_date" value="<!--{$send_date}-->" type='text' readonly="readonly" >
            <select class="form-control" id="start_time">
                <option value="">请选择开始时间</option>
                <!--{foreach name=start item=start from=$send_start_time}-->
                <option value="<!--{$start.itemName}-->"><!--{$start.itemName}--></option>
                <!--{/foreach}-->
            </select>
            <select class="form-control" id="end_time">
                <option value="">时间段结束时间</option>
                <!--{foreach name=end item=end from=$send_end_time}-->
                <option value="<!--{$end.itemName}-->"><!--{$end.itemName}--></option>
                <!--{/foreach}-->
            </select>
            <!--add yim.hu 20141128 FUN-BK-0036 新增订单爆单提示 --start-->
            <input id='hidden_start_time'type='hidden' />
            <input id='hidden_end_time'type='hidden' />
            <!--add yim.hu 20141128 FUN-BK-0036 新增订单爆单提示 --end-->
            <button type="button" class="btn btn-primary input-sm" onclick="bill.checkDeliveryTime.check()">确定</button>
        </div>
        <div id="send_time_text" style="display: none;"></div>
        <!--add yim.hu 20141126 FUN-BK-0036 新增订单爆单提示 --start-->
        <!--增加一个span方便于提示-->
        <span id='tishi_baodan' style='color:red;display:none'>该时间未做爆单判断，如需判断，请点击“修改”</span>
        <!--add yim.hu 20141126 FUN-BK-0036 新增订单爆单提示 --end-->
    </div>

</div>
<!--配送时间    结束-->


<!--会员收货地址  开始-->
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">会员收货地址</h3>
    </div>
    <ul class="list-group radio-box">
        <li class="list-group-item" id="address_list">
            <button type="button" class="btn btn-default" style="width: 50%;float: left;" onclick="bill.deliver.alter.open(0);">点击新增收货地址</button>
            <button type="button" class="btn btn-default" style="width: 50%;" onclick="bill.take.open(0);">选择自提点</button>
        </li>
    </ul>

    <div class="panel-body">
        &nbsp;运费:
        <span class="freight_noAuth">&nbsp;&nbsp;&nbsp;&nbsp;</span>
            <span class="freight_isAuth" style="display: none;">
                <input type="text" class="form-control input-sm" id="alterFreight" style="width: 100px;display: inline-block;">
                <button type="button" class="btn btn-primary input-sm" id="up_freight_bt" onclick="bill.upFreight.check();">修改</button>
            </span>
        &nbsp;&nbsp;&nbsp;<b id="distribution"></b>
        &nbsp;&nbsp;&nbsp;<b id="no_match" style="color: #ff0000;"></b>
    </div>
</div>
<!--会员收货地址  结束-->


<!--配送方式    开始-->
<div class="panel panel-default" id="send_box" style="display: none;">
    <div class="panel-heading">
        <h3 class="panel-title">配送方式</h3>
    </div>
    <ul class="list-group radio-box" id="send_list"></ul>
</div>
<!--配送方式    结束-->

<!--支付方式    开始-->
<div class="panel panel-default" id="pay_1">
    <div class="panel-heading">
        <h3 class="panel-title">支付方式</h3>
    </div>
    <ul class="list-group radio-box" id="pay_list"></ul>
</div>
<!--支付方式    结束-->


<!---代付订单   开始-->
<div class="panel panel-default" id="payment_1">
    <div class="panel-heading">
        <h3 class="panel-title">代付订单</h3>
    </div>
    <div class="panel-body form-inline">
        <div class="form-group">
            <input type="text" class="form-control" name="paying_agent_code" id="paying_agent_code" placeholder="请输入代付订单编号">
        </div>
        <button type="button" class="btn btn-primary" id="paying_agent_confirm" onclick="bill.paying_agent.check()">确定</button>
        <table class="table table-striped table-hover" style="width: 700px;margin-top: 10px;" id="paying_agent_table">
            <thead>
            <tr>
                <th>订单编号</th>
                <th class="tac">收货人</th>
                <th class="tac">应收金额</th>
                <th class="tac">操作</th>
            </tr>
            </thead>
            <tbody id="paying_agent_list"></tbody>
        </table>
    </div>
</div>
<!---代付订单   结束-->

<!--使用优惠券   开始-->
<div class="panel panel-default" id="coupon_1">
    <div class="panel-heading">
        <h3 class="panel-title">使用优惠券</h3>
    </div>
    <div class="panel-body form-inline">
        <div class="form-group">
            <label class="sr-only" for="coupon_code">优惠券</label>
            <input type="text" class="form-control"  id="coupon_code" placeholder="请输入优惠券编码">
        </div>
        <button type="button" class="btn btn-primary" id="coupon_add" onclick="bill.coupon.useCoupon()">使用</button>
        <div id="has_use_coupon" style="margin-top: 10px;">

        </div>
        <!--{if isset($coupon_array) && $coupon_array}-->
        <table class="table table-bordered" style="width: 700px;margin-top: 10px;">
            <tr>
                <th width="*" style="text-align: center;">优惠券编码</th>
                <th width="120" style="text-align: center;">抵扣金额</th>
                <th width="120" style="text-align: center;">使用限额</th>
                <th width="120" style="text-align: center;">优惠券类型</th>
                <th width="120" style="text-align: center;">操作</th>
            </tr>
            <!--{foreach name=coupon item=coupon from=$coupon_array}-->
            <tr>
                <td style="text-align: center;"><!--{$coupon.code|default:''}--><span class="red">  <!--{$coupon.stat_name|default:''}--></span></td>
                <td style="text-align: center;"><!--{$coupon.amount|string_format:"%.2f"|default:''}--></td>
                <td style="text-align: center;"><!--{$coupon.limitMoney|string_format:"%.2f"|default:''}--></td>
                <td style="text-align: center;">
                    <!--{if $coupon.useType == 1}-->券<!--{else}-->红包<!--{/if}-->
                </td>
                <td style="text-align: center;"><button code="<!--{$coupon.code|default:''}-->" <!--{if $coupon.stat neq 1}-->disabled<!--{/if}--> class="form-control input-sm coupon_choose">选择</button></td>
            </tr>
            <!--{/foreach}-->
        </table>
        <!--{/if}-->
    </div>
</div>
<!--使用优惠券   结束-->

<!--使用代金卡   开始-->
<div class="panel panel-default" id="gift_card_1">
    <div class="panel-heading">
        <h3 class="panel-title">使用现金卡</h3>
    </div>
    <div class="panel-body form-inline">

        <div id="form-card" name="form-card">
            <div class="form-group">
                <input type="text" class="form-control" name="card_pwd" id="card_pwd" placeholder="请输入卡密码">
            </div>
            <button type="button" class="btn btn-primary" id="use_card" onclick="bill.card.check()">使用</button>
            <table class="table table-striped table-hover" id="use_card_table" style="width: 700px;margin-top: 10px;">
            </table>
        </div>
    </div>
</div>
<!--使用代金卡   结束-->

<!--使用积分   开始-->
<div class="panel panel-default" id="integral_1">
    <div class="panel-heading">
        <h3 class="panel-title">使用积分&nbsp;&nbsp;<span style="color: red;"><!--{$customer_array.points}-->&nbsp;&nbsp;可抵扣金额:<!--{$customer_array.points_price}--></span></h3>
    </div>
    <div class="panel-body form-inline">
        <div class="form-group">
            <input type="text" class="form-control" id="points_number" pointsPrice="<!--{$customer_array.points_price}-->" placeholder="请输入抵扣金额">
        </div>
        <button type="button" class="btn btn-primary" id="use_points">使用</button>
        &nbsp;&nbsp;<span style="color: #808080;display: none;" id="points_sign"></span>
    </div>
</div>
<!--使用积分   结束-->

<!--使用余额   开始-->
<div class="panel panel-default" id="balance_1">
    <div class="panel-heading">
        <h3 class="panel-title">使用余额&nbsp;&nbsp;<span class="red"><!--{$customer_array.cash}--></span></h3>
    </div>
    <div class="panel-body form-inline">
        <div class="form-group">
            <input type="text" class="form-control" id="balance_number" placeholder="请输入余额">
        </div>
        <button type="button" class="btn btn-primary" id="use_balance" onclick="bill.balance.check()">使用</button>
    </div>
</div>
<!--使用余额   结束-->


<!--会员发票    开始-->
<div class="panel panel-default" id="invoice_1">
    <div class="panel-heading">
        <h3 class="panel-title">会员发票 <span id="card_is_invoice_sign" style="font-size: 12px;color: #b0916a;"></span></h3>
    </div>
    <ul class="list-group radio-box">
        <li class="list-group-item">
            <input type="radio" id="invoice-square-radio-0" name="invoice-radio">
            <label for="invoice-square-radio-0">不开发票</label>
        </li>
        <li class="list-group-item" id="invoice_list">
            <button type="button" class="btn btn-default" style="width: 100%;" onclick="bill.invoice.edit.open(0);">点击新增发票</button>
        </li>
    </ul>
    <div class="panel-footer form-horizontal">
        <div class="form-group" style="margin-bottom:0;">
            <label for="invoice_content" class="col-sm-2 control-label" style="width: 100px;">发票内容</label>
            <div class="col-sm-10">
                <select class="form-control" id="invoice_content" style="width: 200px;">
                    <!--{foreach from=$invoice_content_array item=invoice_content}-->
                    <option value="<!--{$invoice_content.itemID}-->"><!--{$invoice_content.itemName}--></option>
                    <!--{/foreach}-->
                </select>
            </div>
        </div>
    </div>
</div>
<!--会员发票    结束-->


<!--配送备注    开始-->
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">配送备注</h3>
    </div>
    <div class="panel-body">
        <textarea class="form-control" style="height: 70px; width: 100%;" id="remark"></textarea>
    </div>
</div>
<!--配送备注    结束-->


<!--内部留言    开始-->
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">内部留言</h3>
    </div>
    <div class="panel-body">
        <textarea class="form-control" style="height: 70px; width: 100%;" name="bill_remark" id="bill_remark"></textarea>
    </div>
</div>
<!--内部留言    结束-->
<div class="bottom_fixbox" style="width: 100%;left:0;margin-left: 0;">
    <div class="rectbox tac">
        赠送总积分：<span class="red" id="total_points">0</span>&nbsp;
        商品总数量：<span class="red" id="total_amount">0</span>&nbsp;
        商品总金额：<span class="red" id="bill_totalPaid">0.00</span>&nbsp;
        订单金额：<span class="red" id="bill_money">0.00</span>&nbsp;
        运费：<span class="red" id="deliver_feePaid">0.00</span>&nbsp;
        立减金额：<span class="red" id="total_subtract_money">0.00</span>&nbsp;
        应收总金额：<span class="red" id="total_receivable_money">0.00</span>&nbsp;
        <input type="button" value="授权" class="btn" id="btn_auth" onclick="bill.serviceAccredit.check();" />&nbsp;
        <input type="button" value="提交" class="btn" onclick="bill.global.submit.open();" />&nbsp;
        <input type="button" value="关闭" class="btn" onclick="bill.closeW();" />
    </div>

</div>
<!--{include file='comm/footer.tpl'}-->
</div>
<!--{include file='comm/deliver.tpl'}-->
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=<!--{$ebsig_comm.global_set.baidu_map_ak}-->"></script>
<script type="text/javascript">
	//mod yim.hu 20141129 FUN-BK-0036 新增订单爆单提示 --start
	//获取点击时间
    //$('#send_date').datepicker();
	jQuery('#send_date').datepicker({
		onSelect: function(){			
			//首先判断是否有地址
			var distribution_id = $('#distribution').attr('key');
			if(distribution_id>0){
				E.loadding.open('正在努力加载中...');
				var send_date = $('#send_date').val();
            	$.ajax({
            		url: "/invokingAjax-shop/default/checkout.ajax?operFlg=24",
    	            data: {
    	            	distribution_id : distribution_id,
    	            	send_date	:  send_date
    	            },
    	            type: "POST",
    	            success: function(data){  
    	            $('#tishi_baodan').hide();	           
    	            E.loadding.close()
    	            	var data = eval('(' + data + ')');

                        var time_str = $('#start_time').val().split(',')[0];
    	            	//先清空开始时间
    	            	$('#start_time').html('');   	            		
    	            	$('#start_time').append("<option value=''>请选择开始时间</option>")
    	            	$.each(data,function(i,key){

                            var isselected = "";
                            if(key.itemName ==time_str)
                            {
                                isselected = "selected";
                            }

	            			if(key.h==1){
	            				if($('#send_time_text').is(":hidden")==false){
	            					$('#tishi_baodan').show();
	            				}
                                $('#start_time').append("<option value='"+key.itemName+",1' " +isselected + " >"+key.itemName+" (爆单)</option>");
                            }else{
                                $('#start_time').append("<option value='"+key.itemName+"' " +isselected + " >"+key.itemName+"</option>");

                            }
    	            	}); 	
            	    }            
            	});  							
			}								
		}	
	});
	//mod yim.hu 20141129 FUN-BK-0036 新增订单爆单提示 --end        
    var bill = {

        args: {

            isAuth: 0,

            code: '<!--{$code}-->',

            orders_code:'<!--{$code}-->',

            bill_no: "",

            pcustID: "<!--{$customer_array.pcustID}-->",

            mobile: "<!--{$customer_array.mobile}-->",

            custname: "<!--{$customer_array.custname}-->",

            cashAmt: 0,

            freight: 0,

            balance: 0,

            source: "<!--{$source}-->",

            billType : "<!--{$billType}-->",

            preBillType:$("#billType").val(),

            buy_log: {
                pcustID: <!--{$buy_log_array.pcustID}-->,
                deliverID: <!--{$buy_log_array.deliverID|default:0}-->,
                send_region_id: <!--{$buy_log_array.send_region_id|default:0}-->,
                payTypeID: <!--{$buy_log_array.payTypeID|default:0}-->,
                pay_type: <!--{$buy_log_array.pay_type|default:0}-->,
                payment_method_id: <!--{$buy_log_array.payment_method_id|default:0}-->,
                invoiceID: <!--{$buy_log_array.invoiceID|default:-1}-->,
                send_time_id: <!--{$buy_log_array.deliver_send_time_id|default:0}-->,
            },

            total: { },
        },

        //城市跳转
        city_confirm:function( ){
            self.location = "/quanliadmin/app/bill/billEdit.pscript?operFlg=3&pcustID="+bill.args.pcustID+"&cityid="+bill.cityId;
        },

        city_cancal:function( ){
            if(bill.preCityId != bill.cityId){
                $("#billCity").val(bill.preCityId);
            }
        },

        //关闭窗口
        closeW:function(){
            E.confirm("关闭订单需谨慎，关闭后不可恢复当前操作信息，是否要继续？", "E.closeWindows");
        }

    };


    $(window).ready(function() {

        $('#invoice-square-radio-0').iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '20%' // optional
        });

        $('#invoice-square-radio-0').on('ifClicked', function() {
            bill.invoice.choose.start(0);
        });

        var t = $("#billType").val();
   
        //判断是否为试吃订单
        if(t==9 ){
            $("#foretaste").css("display","block");
            $("#promotionBill").remove();
            $("#payment_1").remove();
            $("#payment_1").remove();
            $("#pay_1").remove();
            $("#coupon_1").remove();
            $("#gift_card_1").remove();
            $("#integral_1").remove();
            $("#balance_1").remove();
            $("#invoice_1").remove();
            $("#billCity").attr("disabled",true);
            $("#urgent").attr("disabled",true);
            $("#billPlatform").attr("disabled",true);
            $("#billType").attr("disabled",true);
            $("#billPromotion").attr("disabled",true);
        }


    });

</script>
<script language="JavaScript" src="/quanliadmin/docroot/js/bill.js?t=20150323" type="text/javascript"></script>
<script type="text/javascript">
    bill.global.load.start();
</script>
<!--add by JunHui.Li FUN-BK-0050 模糊快捷查询促销渠道功能 start-->
<script>
    $(".js-example-data-array-selected").select2({
        data: <!--{$buy_arrays}-->
    })
</script>
<!--add by JunHui.Li FUN-BK-0050 模糊快捷查询促销渠道功能 end-->
</body>
</html>
